home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 12824 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.1 KB

  1. Path: news.infi.net!usenet
  2. From: root <root@pcjournal.infi.net>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: String problem
  5. Date: Tue, 02 Apr 1996 19:04:41 -0500
  6. Organization: InfiNet
  7. Message-ID: <3161C099.187E8082@pcjournal.infi.net>
  8. References: <826_9604020401@intermedia.qc.ca>
  9. NNTP-Posting-Host: h-avantgarde.dc.infi.net
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.01 (X11; I; Linux 1.2.13 i486)
  14.  
  15. Trinomic Technologie wrote:
  16. > "Can anyone tell me why NameCheck = 0 when I run the program"
  17. > Your program will give you always this result because you can't use "==" to
  18. > compare strings:
  19. > if (WhereName == "John")
  20. > {
  21. >        NameCheck = 1;
  22. > }
  23. > You must use fonction "strcmp()" to compare 2 strings
  24. >  ry this:
  25. > #include "string.h"
  26. > if (strcmp(WhereName, "John") == 0)
  27. > ...
  28. > Stephane Mercier
  29. > >> De : Trinomic.Technologie@f700.n167.z1.fidonet.org ( Fidonet: Trinomic Technologie 1:167/700 )
  30. >    Via: root@intermedia.qc.ca ( 1:242/847 )
  31.  
  32. Of course if you want to you could overload the "=" operator to enable
  33. you to compare strings in that manner.
  34.